from __future__ import generators
import socket
import sys
import posnet_tcp_client
from posnet_overlay_messages import *

def send_answers_test(host,port_number):
    print "send fake answers"
    sys.stdout.flush()
    myid = (host,1234)
    m  = posnet_ping_reply_message(   myid,  (host,port_number) , dict())
    posnet_tcp_client.send_answer_message( host,port_number,m )
    posnet_tcp_client.send_answer_message( host,port_number,m )
    posnet_tcp_client.send_answer_message( host,port_number,m )
    posnet_tcp_client.send_answer_end(host,port_number,myid)
    

if __name__ == "__main__":
    import sys
    host = socket.gethostname()
    ports = [int(x) for x in sys.argv[1:]]
    for port in ports:
        send_answers_test(host,port)
    